package com.blocks.blocks;

import com.blocks.ScriptBlocksApplication;
import com.blocks.gui.BlockListGroup;
import com.jme3.math.ColorRGBA;

public class WirelessReceiverBlock extends Block {
	
	private static Integer WIRELESS_FREQUENCY = 0;
	
	public WirelessReceiverBlock() {	
		super();
	}
	public WirelessReceiverBlock(String name, Long masterId) {
		super(name,masterId);
		this.setBlockListGroup(BlockListGroup.FREQUENCY);
	}
	
	
	
	@Override
	public void init() {
		setTextureRow(0.0f);
		setTextureColumn(11.0f);
		super.init();
	}
	@Override
	public void updateLogicalState(float tpf) {
		
		super.updateLogicalState(tpf);
		if(this.isPowered()){			
			Integer wirelessFrequency = ScriptBlocksApplication.getInstance().getWirelessFrequency(WIRELESS_FREQUENCY);
			if(wirelessFrequency!=null){
				this.setAllFrequency(wirelessFrequency);
			}else {
				this.setAllFrequency(0);
			}
			
		} else {
			setColor(ColorRGBA.Gray);
		}
	}
}
